home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 1992 August / info-mac-1992.iso / Applications (app) / Earth Plot / ep.main.c < prev    next >
Text File  |  1987-12-25  |  6KB  |  188 lines

  1. /*** Earthplot V3.0
  2.  
  3. Another revision of Earthplot. This one was prompted by the fact that
  4. System 4.1 broke programs written in the old versions of Megamax C and 
  5. guess what language Earthplot was written in?  So it has been rewritten
  6. to compile under Think Technologies' LightspeedC (V2.13 used for V3.0).  
  7. Also, rather than SimpleTools, the TSkel package from Paul DuBois was 
  8. used as the platform.
  9.  
  10. Enhancements include:
  11.  
  12.     - full clipboard support (both bitmaps and PICTs)
  13.     - a choice of using either integer or floating point math
  14.     - ability to resize the earth window (for those BIG new screens)
  15.     - simple color support for color capable machines
  16.     - the raw earth data now lives in an 'eDAT' resource
  17.     - other minor cosmetic and other changes
  18.  
  19. -- The Black Swamp Software Company
  20. -- AKA michael peirce, reachable at... [as of December 1987]
  21.  
  22.         ARPANET:    peirce@lll-crg.llnl.gov
  23.         MCI-Mail:    mpeirce
  24.         Delphi:        mpeirce
  25.         US Mail:    1265 Braddock Ct.
  26.                     San Jose, CA 95125
  27.  
  28. ***/
  29.  
  30. /*** Earthplot V2.0
  31. Here's a new version of earthplot.  For those who missed it, it is
  32. a program that plots an outline of the earth given the latitute,
  33. longitude, and altitude.  I really liked the program but had problems
  34. with it's performance (5-6 minutes to draw the earth).
  35.  
  36. The new version is vastly improved.  The plot is completed in about
  37. 35 seconds.  How did I do it?  I got rid of the unnecessary use of
  38. floating point and substituted integer arithmetic with implied decimal
  39. places (1.0 is represented as 10000).  Accuracy is good enough so that
  40. out of 7000 data points, only 400 are off by no more than one pixel.
  41. I also incorporated the data file into a code segment so the disk i/o
  42. involved in reading the data is also eliminated.
  43.  
  44. A binhex'ed version of the new program is posted as a separate article
  45. so you won't have to compile this to enjoy it.
  46.  
  47. Enjoy!!
  48.   Marsh Gosnell   usenet: ihnp4!lzma!mkg
  49. ***/
  50.  
  51. /**
  52.  ** EarthPlot V1.0 -- a program to draw the earth as viewed from space.
  53.  **
  54.  ** Written by:    
  55.  **        Michael Peirce (peirce@lll-crg.arpa)
  56.  **        1680 Braddock Ct.
  57.  **        San Jose, CA 95125
  58.  **
  59.  ** Significant performance improvements by:
  60.  **         Marsh Gosnell
  61.  **         35 Godfrey Road
  62.  **         Montclair, NJ  07043
  63.  **
  64.  **    ...in Megamax C (version 2.1)   w/ the SimpleTools package
  65.  **
  66.  ** Based on Microplot program written in Fortran by Richard Heurtley
  67.  ** (This can be found in file B900:MICROPLOT.FTN on the MTS system 
  68.  **  at Rensselear Polytechnic Institute in Troy, New York)
  69.  **
  70.  ** Who    When            What
  71.  ** ===    ===========        ====================================
  72.  ** mrp    01-dec-1985        Final work done for version 1.0
  73.  ** mkg 20-dec-1985        Performance improvements
  74.  ** mrp 15-aug-1987        V3.0 in Lightspeed C w/ TSkel
  75.  **/
  76.  
  77. /** [2.0 notes]
  78.  ** The performance improvments are:
  79.  **
  80.  ** - use of integer arithmetic where possible.  All values are small
  81.  **   enough so that using integer arithmetic with 4 implied decimal
  82.  **   places (e.g., multiplying by 10000) yields sufficient accuracy.
  83.  **   (Out of 7000 displayed points, 400 are off by 1 pixel).
  84.  **
  85.  ** - data is kept in a separate code segment.  avoids disk i/o
  86.  **
  87.  ** - new lmul routine.  The Megamax lmul routine always does things the
  88.  **   hard way even if the two long values are shorts.  The new lmul will
  89.  **   lmul will run really fast if the two values are shorts (which they
  90.  **   usually are in this case).
  91.  **/
  92.  
  93. /** [1.0 notes]
  94.  ** Because Earthplot is in such a state (and because I did it 
  95.  ** primarily as a learning experience) both source and executable
  96.  ** are being placed into the public domain.  I encourage anyone to
  97.  ** pick up on this start and expand on it's theme.  All I ask is
  98.  ** that if anyone does improve on this program them send the
  99.  ** results back to me (either via the net or other means).
  100.  **
  101.  ** The following is a list of possible extensions:
  102.  **
  103.  ** - support cut & paste to the clipboard
  104.  **
  105.  ** - support resizing the drawing window to allow various sizes
  106.  **   of earth plots
  107.  **
  108.  ** - save plots directly into a file (a save option)
  109.  **
  110.  ** - either a scripting facility or a batch runable version so
  111.  **   that a large number of plots can be generated without human
  112.  **   interaction.  This would allow one to either feed these plots
  113.  **   into something like Videoworks to create a "real-time" rotation
  114.  **   of the earth or a special "player" program that would do this.
  115.  **   (Note: this has already been done for my roommate's IBM-PC clone.
  116.  **   Come on MacFolks, we can do it better than THEM).
  117.  **
  118.  ** - compress the data (from ASCII into binary data)
  119.  **
  120.  ** - put the data into (a) the data fork of the executable or (b) a
  121.  **   a resource
  122.  **
  123.  ** - improve on hidden line and/or ploting algorithm...
  124.  **
  125.  ** - add a floating point chip to the Mac!!!!! (they did!!! yeah Mac II!)
  126.  **/
  127.  
  128. #include    "ep.const.h"
  129. #include    "ep.extern.h"
  130. #include    <MenuMgr.h>
  131. #include    <DialogMgr.h>
  132. #include    "EventMgr.h"
  133.  
  134. extern    DoAbout();
  135. extern    DoFileMenu();
  136. extern    DoEditMenu();
  137. extern    DoEarthMenu();
  138.  
  139. WindowPtr    cWindow;
  140. WindowPtr    eWindow;
  141.  
  142. main ()
  143. {
  144. MenuHandle    m;
  145. Boolean        b;
  146. EventRecord myevent;
  147.  
  148.     SkelInit ();
  149.  
  150.     /* when glue for SysEnvirons exists use it, but until then… */
  151.     hasColorQD = !(ROM85 & 0xC000); /* from TechNote 118 */
  152.  
  153.     b = GetNextEvent (everyEvent, &myevent); /* but override w/ OPTION key */
  154.     if (myevent.modifiers && optionKey) {
  155.         hasColorQD = TRUE;
  156.     }
  157.  
  158.     /*  I've left the color code in, but only as a basis for further work.  It should
  159.         really be done using the new ColorQuickDraw calls, rather than the only stuff.
  160.         The main problem now, is that the image is saved a a bitmap and this isn't
  161.         good enough with CQD, we need to save it as a color PixMap.  Well, fodder for
  162.         a V3.1!  ...mrp
  163.     */    hasColorQD = FALSE;
  164.  
  165.     SkelApple ("\pAbout Earthplot…", DoAbout);
  166.  
  167.     m = NewMenu (2, "\pFile");
  168.     AppendMenu  (m, "\pQuit/Q");
  169.     SkelMenu    (m, DoFileMenu, nil);
  170.  
  171.     m = NewMenu (3, "\pEdit");
  172.     AppendMenu  (m, "\pUndo/Z;(-;Cut/X;Copy/C;Paste/V;Clear");
  173.     SkelMenu    (m, DoEditMenu, nil);
  174.  
  175.     m = NewMenu(4, "\p\265EarthPlot");
  176.     AppendMenu (m, "\pDraw Earth/D");
  177.     AppendMenu (m, "\pOptions…/O");
  178.     if (hasColorQD) 
  179.         AppendMenu (m, "\pColors…/K");
  180.     SkelMenu   (m, DoEarthMenu, nil);
  181.  
  182.     epInit();
  183.  
  184.     SkelMain ();        /* loop 'til Quit selected */
  185.  
  186.     SkelClobber ();        /* clean up */
  187. }
  188.